package com.atomscat.lottery.controller.admin;

import com.atomscat.lottery.entity.db.LotteryActivityEntity;
import com.atomscat.lottery.entity.vo.request.DrawLotteryRequest;
import com.atomscat.lottery.entity.vo.request.LotteryActivityRequest;
import com.atomscat.lottery.entity.vo.request.PageLotteryActivityRequest;
import com.atomscat.lottery.entity.vo.request.UpdateLotteryActivityRequest;
import com.atomscat.lottery.entity.vo.response.BaseResponse;
import com.atomscat.lottery.entity.vo.response.LotteryRecordResponse;
import com.atomscat.lottery.service.LotteryActivityService;
import com.atomscat.lottery.service.VoBaseRespTransformService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Mono;

import java.io.Serializable;

@RestController
@RequestMapping("/admin/lottery/activity")
@RequiredArgsConstructor
public class LotteryActivityController {
    private final VoBaseRespTransformService voBaseRespTransformService;
    private final LotteryActivityService lotteryActivityService;

    @PostMapping("/page")
    public BaseResponse<Page<LotteryActivityEntity>> lotteryActivityPage(@RequestBody PageLotteryActivityRequest pageLotteryActivityRequest) {
        return voBaseRespTransformService.transformSuccessful(lotteryActivityService.lotteryActivityPage(pageLotteryActivityRequest));
    }

    @PostMapping("/create")
    public BaseResponse<Boolean> createLotteryActivity(@Valid @RequestBody LotteryActivityRequest lotteryActivityRequest) {
        return voBaseRespTransformService.transformSuccessful(lotteryActivityService.createLotteryActivity(lotteryActivityRequest));
    }

    @PostMapping("/update")
    public BaseResponse<Boolean> updateLotteryActivity(@Valid @RequestBody UpdateLotteryActivityRequest lotteryActivityRequest) {
        return voBaseRespTransformService.transformSuccessful(lotteryActivityService.updateLotteryActivity(lotteryActivityRequest));
    }

    @GetMapping("/recruiting")
    public BaseResponse<Boolean> recruitingLotteryActivity(@RequestParam Long id) {
        return voBaseRespTransformService.transformSuccessful(lotteryActivityService.recruitingLotteryActivity(id));
    }

    @GetMapping("/active")
    public BaseResponse<Boolean> activeLotteryActivity(@RequestParam Long id) {
        return voBaseRespTransformService.transformSuccessful(lotteryActivityService.activeLotteryActivity(id));
    }

    @PostMapping("/draw")
    public BaseResponse<LotteryRecordResponse> drawLottery(@Valid @RequestBody DrawLotteryRequest drawLotteryRequest) {
        return voBaseRespTransformService.transformSuccessful(lotteryActivityService.drawLottery(drawLotteryRequest));
    }
}
